#ifndef __MY_LOGGER_H__
#define __MY_LOGGER_H__
#include <stdio.h>
#include <time.h>

#define INF 0
#define DBG 1
#define ERR 2
#define DEFAULT_LOG_LEVEL DBG

#define LOGGER(level, format, ...) do {\
    if(level < DEFAULT_LOG_LEVEL) break;\
    time_t t = time(nullptr);\
    struct tm* lt = localtime(&t);\
    char buffer[32] = {0};\
    strftime(buffer, 31, "%H:%M:%S", lt);\
    fprintf(stdout, "[%s] [%s line:%d] " format "\n", buffer, __FILE__, __LINE__, ##__VA_ARGS__);\
}while(0)

#define ILOG(format, ...) LOGGER(INF, format, ##__VA_ARGS__)
#define DLOG(format, ...) LOGGER(DBG, format, ##__VA_ARGS__)
#define ELOG(format, ...) LOGGER(ERR, format, ##__VA_ARGS__)

#endif